fixed codesandbox relative to absolute imports#3538
Merged
nicolethoen merged 6 commits intoAug 9, 2023
Conversation
Collaborator
|
PF4 preview: https://patternfly-org-pr-3538-v4.surge.sh/v4 |
jenny-s51
reviewed
May 17, 2023
Contributor
There was a problem hiding this comment.
This is looking awesome @evwilkin!
Looked through a bunch of codesandbox demos that use relative import paths and lots of them have now been resolved with this update... Some icons within certain demos are still not rendering due to some residual image paths that should updated in react; opened patternfly/patternfly-react#9140 to track these and assigned myself to these cleanup tasks
LGTM 👍
jenny-s51
previously approved these changes
Jun 23, 2023
2a84dc0 to
d7789ae
Compare
nicolethoen
approved these changes
Aug 9, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3525
This PR updates the conversion of relative import paths to absolute import paths, to be used in Codesandbox where the relative files aren't present.
Previously:
mdx-hast-to-jsxwould identify any relative imports in example code (import Something from '../Something.js'), parse out the name of the imported item, and build a map matching this relative imported item to the absolute import path for it{ Something: '@patternfly/some-package/Something.js' }codesandbox.jsto use simple string replacement to swap out the relative path with the absolute path in the example code before sending to Codesandbox exampleNow:
mdx-hast-to-jsxmaps the relative import path (not the name of the imported item) directly to the absolute import path{ '../../Something.js': '@patternfly/some-package/Something.js' }import { rows, columns } from '../../Data.js') - what is being imported doesn't really matter, we're just concerned with finding the relative file where it's coming from and getting the absolute path to that file.